
export function getCurrentTime(time){
  let date = new Date(time);

  let hour = date.getHours() < 10 ? '0'+ date.getHours() : date.getHours();
  let minute = date.getMinutes() < 10 ? '0'+ date.getMinutes() : date.getMinutes();
  return hour + ":" + minute;
}

export function getCurrentDate(d,time){
  let date = new Date(time);
  let month;
  let day;
  if(!day){
     let newDate = date.setDate(date.getDate() + d);
     newDate = new Date(newDate);
     month = newDate.getMonth() + 1  < 10 ? '0'+ (newDate.getMonth() + 1 ) : newDate.getMonth() + 1;
     day = newDate.getDate() < 10 ? '0'+ newDate.getDate() : newDate.getDate();
  }
  else{
    month = date.getMonth() + 1  < 10 ? '0'+ (date.getMonth() + 1 ) : date.getMonth() + 1;
    day = date.getDate() < 10 ? '0'+ date.getDate() : date.getDate();
  }
  return month + '/' + day;
}

export function getBefore(d,time){
  let date = new Date(time);
  let year;
  let month;
  let day;
  if(!day){
     let newDate = date.setDate(date.getDate() - d);
     newDate = new Date(newDate);
     year = newDate.getFullYear();
     month = newDate.getMonth() + 1  < 10 ? '0'+ (newDate.getMonth() + 1 ) : newDate.getMonth() + 1;
     day = newDate.getDate() < 10 ? '0'+ newDate.getDate() : newDate.getDate();
  }
  else{
    year = date.getFullYear();
    month = date.getMonth() + 1  < 10 ? '0'+ (date.getMonth() + 1 ) : date.getMonth() + 1;
    day = date.getDate() < 10 ? '0'+ date.getDate() : date.getDate();
  }
  return year + '-' + month + '-' + day;
}

export function getCurrentWeek(time){
  let date = new Date(time);

  let arr = new Array("日", "一", "二", "三", "四", "五", "六");
  let weekday = '周' + arr[date.getDay()];
  return weekday;
}